]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Indicate when do-not-disturb is on
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 17 Jan 2020 16:26:08 +0000 (17:26 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 22 Jan 2020 21:55:28 +0000 (21:55 +0000)
When do-not-disturb is enabled, non-critical notifications will not
be shown as banners. It therefore makes sense to indicate that state
to the user, so they don't accidentally miss notifications.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/239

js/ui/dateMenu.js

index 9bdd2c4d10a3cf3dca02497b6415cfe78426a8ab..63bcbdf5ebc0afbdcdb848191da262db6f10ebf7 100644 (file)
@@ -432,7 +432,6 @@ var MessagesIndicator = GObject.registerClass(
 class MessagesIndicator extends St.Icon {
     _init() {
         super._init({
-            icon_name: 'message-indicator-symbolic',
             icon_size: 16,
             visible: false,
             y_expand: true,
@@ -440,6 +439,13 @@ class MessagesIndicator extends St.Icon {
         });
 
         this._sources = [];
+        this._count = 0;
+        this._doNotDisturb = false;
+
+        this._settings = new Gio.Settings({
+            schema_id: 'org.gnome.desktop.notifications',
+        });
+        this._settings.connect('changed::show-banners', this._sync.bind(this));
 
         Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
         Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
@@ -447,6 +453,11 @@ class MessagesIndicator extends St.Icon {
 
         let sources = Main.messageTray.getSources();
         sources.forEach(source => this._onSourceAdded(null, source));
+
+        this.connect('destroy', () => {
+            this._settings.run_dispose();
+            this._settings = null;
+        });
     }
 
     _onSourceAdded(tray, source) {
@@ -463,9 +474,17 @@ class MessagesIndicator extends St.Icon {
     _updateCount() {
         let count = 0;
         this._sources.forEach(source => (count += source.unseenCount));
-        count -= Main.messageTray.queueCount;
+        this._count = count - Main.messageTray.queueCount;
 
-        this.visible = count > 0;
+        this._sync();
+    }
+
+    _sync() {
+        let doNotDisturb = !this._settings.get_boolean('show-banners');
+        this.icon_name = doNotDisturb
+            ? 'notifications-disabled-symbolic'
+            : 'message-indicator-symbolic';
+        this.visible = doNotDisturb || this._count > 0;
     }
 });